#include "beremiz.h"
#ifndef __POUS_H
#define __POUS_H

#include "accessor.h"
#include "iec_std_lib.h"

#if 0
__DECLARE_DERIVED_TYPE(AXIS_REF,INT)
__DECLARE_ENUMERATED_TYPE(MC_BUFFER_MODE,
  MC_BUFFER_MODE__MCABORTING,
  MC_BUFFER_MODE__MCBUFFERED,
  MC_BUFFER_MODE__MCBLENDINGLOW,
  MC_BUFFER_MODE__MCBLENDINGPREVIOUS,
  MC_BUFFER_MODE__MCBLENDINGNEXT,
  MC_BUFFER_MODE__MCBLENDINGHIGH
)
__DECLARE_ENUMERATED_TYPE(MC_HOMING_PROCEDURES,
  MC_HOMING_PROCEDURES__MCHOMEDIRECT,
  MC_HOMING_PROCEDURES__MCHOMELIMITSWITCHPOSITIVE,
  MC_HOMING_PROCEDURES__MCHOMELIMITSWITCHNEGATIVE,
  MC_HOMING_PROCEDURES__MCHOMEABSOLUTESWITCHPOSITIVE,
  MC_HOMING_PROCEDURES__MCHOMEABSOLUTESWITCHNEGATIVE,
  MC_HOMING_PROCEDURES__MCHOMEREFERENCEPULSEPOSITIVE,
  MC_HOMING_PROCEDURES__MCHOMEREFERENCEPULSENEGATIVE,
  MC_HOMING_PROCEDURES__MCHOMEABSOLUTE
)
__DECLARE_ENUMERATED_TYPE(MC_DIRECTION,
  MC_DIRECTION__MCABSOLUTEPOSITION,
  MC_DIRECTION__MCPOSITIVEDIRECTION,
  MC_DIRECTION__MCSHORTESTWAY,
  MC_DIRECTION__MCNEGATIVEDIRECTION,
  MC_DIRECTION__MCCURRENTDIRECTION
)
__DECLARE_DERIVED_TYPE(MC_TP_REF,INT)
__DECLARE_DERIVED_TYPE(MC_TV_REF,INT)
__DECLARE_DERIVED_TYPE(MC_TA_REF,INT)
__DECLARE_ENUMERATED_TYPE(MC_EXECUTION_MODE,
  MC_EXECUTION_MODE__MCIMMEDIATELY,
  MC_EXECUTION_MODE__MCQUEUED
)
__DECLARE_ENUMERATED_TYPE(MC_SOURCE,
  MC_SOURCE__MCACTUALVALUE,
  MC_SOURCE__MCSETVALUE
)
__DECLARE_DERIVED_TYPE(MC_CAMSWITCH_REF,INT)
__DECLARE_DERIVED_TYPE(MC_OUTPUT_REF,INT)
__DECLARE_DERIVED_TYPE(MC_TRACK_REF,INT)
__DECLARE_DERIVED_TYPE(MC_TRIGGER_REF,INT)
__DECLARE_DERIVED_TYPE(MC_CAM_REF,INT)
__DECLARE_DERIVED_TYPE(MC_CAM_ID,INT)
__DECLARE_DERIVED_TYPE(MC_START_MODE,INT)
__DECLARE_DERIVED_TYPE(MC_SYNC_MODE,INT)
__DECLARE_ENUMERATED_TYPE(MC_COMBINE_MODE,
  MC_COMBINE_MODE__MCADDAXES,
  MC_COMBINE_MODE__MCSUBAXES
)
__DECLARE_ARRAY_TYPE(__ARRAY_OF_REAL_6,REAL,[6])
typedef __ARRAY_OF_REAL_6 MC_REAL_ARRAY;
__DECLARE_ARRAY_TYPE(__ARRAY_OF_INT_6,INT,[6])
typedef __ARRAY_OF_INT_6 MC_INT_ARRAY;
#endif

__DECLARE_ENUMERATED_TYPE(LOGLEVEL,
  LOGLEVEL__CRITICAL,
  LOGLEVEL__WARNING,
  LOGLEVEL__INFO,
  LOGLEVEL__DEBUG
)
// FUNCTION
BYTE BITS_BYTE(
  BOOL EN, 
  BOOL *__ENO, 
  BOOL BIT0, 
  BOOL BIT1, 
  BOOL BIT2, 
  BOOL BIT3, 
  BOOL BIT4, 
  BOOL BIT5, 
  BOOL BIT6, 
  BOOL BIT7);
// FUNCTION
WORD BITS_WORD(
  BOOL EN, 
  BOOL *__ENO, 
  BOOL BIT0, 
  BOOL BIT1, 
  BOOL BIT2, 
  BOOL BIT3, 
  BOOL BIT4, 
  BOOL BIT5, 
  BOOL BIT6, 
  BOOL BIT7, 
  BOOL BIT8, 
  BOOL BIT9, 
  BOOL BIT10, 
  BOOL BIT11, 
  BOOL BIT12, 
  BOOL BIT13, 
  BOOL BIT14, 
  BOOL BIT15);
// FUNCTION
UDINT TIMESTAMP(
  BOOL EN, 
  BOOL *__ENO, 
  BOOL USERTC);
// FUNCTION_BLOCK LOGGER// GLOBAL

// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(BOOL,TRIG)
  __DECLARE_VAR(STRING,MSG)
  __DECLARE_VAR(LOGLEVEL,LEVEL)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(BOOL,TRIG0)

} LOGGER;

void LOGGER_init__(LOGGER *data__, BOOL retain);
// Code part
void LOGGER_body__(LOGGER *data__);
// FUNCTION_BLOCK PROC_STATE// GLOBAL

// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(BOOL,ERR_HOME)
  __DECLARE_VAR(WORD,ERR_HOME_ID)
  __DECLARE_VAR(BOOL,ERR_MOVE)
  __DECLARE_VAR(WORD,ERR_MOVE_ID)
  __DECLARE_VAR(BOOL,ERR_MOVE1)
  __DECLARE_VAR(BOOL,ERR_MOVE2)
  __DECLARE_VAR(BOOL,HOME)
  __DECLARE_VAR(BOOL,ACT_MOVE)
  __DECLARE_VAR(BOOL,ACT_MOVE0)
  __DECLARE_VAR(INT,OUT)

  // FB private variables - TEMP, private and located variables

} PROC_STATE;

void PROC_STATE_init__(PROC_STATE *data__, BOOL retain);
// Code part
void PROC_STATE_body__(PROC_STATE *data__);
// FUNCTION_BLOCK STEPPER// GLOBAL

// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(AXIS_REF,AXIS)
  __DECLARE_VAR(REAL,POS)
  __DECLARE_VAR(INT,STATE)
  __DECLARE_VAR(REAL,TARGET)
  __DECLARE_VAR(BOOL,RUN)
  __DECLARE_VAR(BOOL,RUNING)
  __DECLARE_VAR(REAL,SPEED)
  __DECLARE_VAR(REAL,ASPEED)
  __DECLARE_VAR(BOOL,HOME)
  __DECLARE_VAR(REAL,HOMESPEED)
  __DECLARE_VAR(REAL,HOMELOOKUP)
  __DECLARE_VAR(REAL,XIFEN)
  __DECLARE_VAR(MC_DIRECTION,RUN_DIR)
  __DECLARE_VAR(MC_HOMING_PROCEDURES,HOMEMODE)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(MC_BUFFER_MODE,BUFFMODE)
  __DECLARE_VAR(MC_EXECUTION_MODE,MC_SETPOSMODE)
  MC_WRITEPARAMETER MC_WRITEPARAMETER8;
  MC_HOME MC_HOME1;
  MC_MOVEABSOLUTE MC_MOVEABSOLUTE3;
  MC_POWER MC_POWER3;
  MC_READACTUALPOSITION MC_READACTUALPOSITION3;
  PROC_STATE PROC_STATE3;
  MC_SETPOSITION MC_SETPOSITION3;
  MC_WRITEPARAMETER MC_WRITEPARAMETER0;
  MC_WRITEPARAMETER MC_WRITEPARAMETER6;
  __DECLARE_VAR(BOOL,_TMP_MOVE138_ENO)
  __DECLARE_VAR(BOOL,_TMP_MOVE138_OUT)
  __DECLARE_VAR(BOOL,_TMP_OR222_OUT)
  __DECLARE_VAR(REAL,_TMP_DIV167_OUT)

} STEPPER;

void STEPPER_init__(STEPPER *data__, BOOL retain);
// Code part
void STEPPER_body__(STEPPER *data__);
// FUNCTION_BLOCK WK_HYP// GLOBAL

// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(REAL,H)
  __DECLARE_VAR(REAL,CV)
  __DECLARE_VAR(REAL,L)
  __DECLARE_VAR(UINT,OUT)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(UINT,OUT0)
  __DECLARE_VAR(UINT,COUNT)

} WK_HYP;

void WK_HYP_init__(WK_HYP *data__, BOOL retain);
// Code part
void WK_HYP_body__(WK_HYP *data__);
// FUNCTION_BLOCK WK_PID// GLOBAL

// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(REAL,SV)
  __DECLARE_VAR(REAL,CV)
  __DECLARE_VAR(REAL,RANGER)
  __DECLARE_VAR(REAL,KP)
  __DECLARE_VAR(REAL,KI)
  __DECLARE_VAR(REAL,KD)
  __DECLARE_VAR(REAL,OUT)
  __DECLARE_VAR(BOOL,PIDING)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(REAL,ERROR)
  __DECLARE_VAR(REAL,SUMERROR)
  __DECLARE_VAR(REAL,DERROR)
  __DECLARE_VAR(REAL,PERROR)
  __DECLARE_VAR(REAL,LERROR)

} WK_PID;

void WK_PID_init__(WK_PID *data__, BOOL retain);
// Code part
void WK_PID_body__(WK_PID *data__);
// PROGRAM PROGRAM0// Global Function


// Data part
typedef struct {
  // PROGRAM Interface - IN, OUT, IN_OUT variables

  // PROGRAM private variables - TEMP, private and located variables
  __DECLARE_VAR(BOOL,RESET_ALL)
  __DECLARE_VAR(BOOL,GOHOME)
  __DECLARE_VAR(BOOL,WKON1)
  __DECLARE_VAR(BOOL,WKON2)
  __DECLARE_VAR(BOOL,WKON3)
  __DECLARE_VAR(BOOL,WKON4)
  __DECLARE_VAR(REAL,WKSET1)
  __DECLARE_VAR(REAL,WKSET2)
  __DECLARE_VAR(REAL,WKSET3)
  __DECLARE_VAR(REAL,WKSET4)
  __DECLARE_VAR(REAL,WKSET_L)
  __DECLARE_VAR(REAL,TEMP1)
  __DECLARE_VAR(REAL,TEMP2)
  __DECLARE_VAR(REAL,TEMP3)
  __DECLARE_VAR(REAL,TEMP4)
  __DECLARE_VAR(REAL,JIAOZHUN1)
  __DECLARE_VAR(REAL,JIAOZHUN2)
  __DECLARE_VAR(REAL,JIAOZHUN3)
  __DECLARE_VAR(REAL,JIAOZHUN4)
  __DECLARE_LOCATED(REAL,TEMP_IN1)
  __DECLARE_LOCATED(REAL,TEMP_IN2)
  __DECLARE_LOCATED(REAL,TEMP_IN3)
  __DECLARE_LOCATED(REAL,TEMP_IN4)
  __DECLARE_LOCATED(BOOL,LOCALVAR14)
  __DECLARE_LOCATED(BOOL,LOCALVAR15)
  __DECLARE_LOCATED(BOOL,LOCALVAR16)
  __DECLARE_LOCATED(BOOL,LOCALVAR17)
  __DECLARE_VAR(REAL,SPEED1)
  __DECLARE_VAR(REAL,ASPEED1)
  __DECLARE_VAR(REAL,SPEED2)
  __DECLARE_VAR(REAL,ASPEED2)
  __DECLARE_VAR(REAL,SPEED3)
  __DECLARE_VAR(REAL,ASPEED3)
  __DECLARE_VAR(REAL,SPEED4)
  __DECLARE_VAR(REAL,ASPEED4)
  __DECLARE_VAR(REAL,TARGET1)
  __DECLARE_VAR(REAL,POS1)
  __DECLARE_VAR(REAL,TARGET2)
  __DECLARE_VAR(REAL,POS2)
  __DECLARE_VAR(REAL,TARGET3)
  __DECLARE_VAR(REAL,POS3)
  __DECLARE_VAR(REAL,TARGET4)
  __DECLARE_VAR(REAL,POS4)
  __DECLARE_VAR(INT,STATUS1)
  __DECLARE_VAR(INT,STATUS2)
  __DECLARE_VAR(INT,STATUS3)
  __DECLARE_VAR(INT,STATUS4)
  __DECLARE_VAR(BOOL,RUN1)
  __DECLARE_VAR(BOOL,RUN2)
  __DECLARE_VAR(BOOL,RUN3)
  __DECLARE_VAR(BOOL,RUN4)
  __DECLARE_VAR(REAL,HOMESPEED1)
  __DECLARE_VAR(REAL,HOMESPEED2)
  __DECLARE_VAR(REAL,HOMESPEED3)
  __DECLARE_VAR(REAL,HOMESPEED4)
  __DECLARE_VAR(REAL,HOMESPEEDZERO1)
  __DECLARE_VAR(REAL,HOMESPEEDZERO2)
  __DECLARE_VAR(REAL,HOMESPEEDZERO3)
  __DECLARE_VAR(REAL,HOMESPEEDZERO4)
  __DECLARE_VAR(BOOL,HOME1)
  __DECLARE_VAR(BOOL,HOME2)
  __DECLARE_VAR(BOOL,HOME3)
  __DECLARE_VAR(BOOL,HOME4)
  __DECLARE_LOCATED(BOOL,DCMOTOR_RUN)
  __DECLARE_LOCATED(BOOL,DCMOTOR_DIR)
  __DECLARE_LOCATED(UINT,DCMOTOR_SPEED_SET)
  __DECLARE_LOCATED(UINT,DCMOTOR_SPEED)
  __DECLARE_LOCATED(UINT,DCMOTOR_FREQ)
  __DECLARE_LOCATED(INT,DC_MOTOR2_SPEED)
  __DECLARE_LOCATED(BOOL,J1)
  __DECLARE_LOCATED(BOOL,J2)
  __DECLARE_LOCATED(BOOL,J3)
  __DECLARE_LOCATED(BOOL,J4)
  __DECLARE_VAR(BOOL,RUN_EN)
  __DECLARE_VAR(BOOL,TEMPUSE1)
  MC_HOME MC_HOME0;
  __DECLARE_VAR(AXIS_REF,AXIS_0)
  __DECLARE_VAR(AXIS_REF,AXIS_1)
  __DECLARE_VAR(AXIS_REF,AXIS_2)
  __DECLARE_VAR(AXIS_REF,AXIS_3)
  __DECLARE_VAR(MC_CAM_REF,MC_CAMTABLESELECT1)
  WK_PID WK_PID0;
  __DECLARE_VAR(REAL,KP)
  __DECLARE_VAR(REAL,KI)
  __DECLARE_VAR(REAL,KD)
  __DECLARE_LOCATED(UINT,PWM1)
  __DECLARE_LOCATED(UINT,PWM2)
  __DECLARE_LOCATED(UINT,PWM3)
  __DECLARE_LOCATED(UINT,PWM4)
  __DECLARE_VAR(REAL,XIFEN1)
  __DECLARE_VAR(REAL,XIFEN2)
  __DECLARE_VAR(REAL,XIFEN3)
  __DECLARE_VAR(REAL,XIFEN4)
  MC_MOVEABSOLUTE MC_MOVEABSOLUTE0;
  MC_POWER MC_POWER0;
  __DECLARE_VAR(MC_HOMING_PROCEDURES,HOME_P)
  __DECLARE_VAR(MC_HOMING_PROCEDURES,HOME_N)
  __DECLARE_VAR(MC_DIRECTION,DIR_P)
  __DECLARE_VAR(MC_DIRECTION,DIR_N)
  __DECLARE_VAR(MC_BUFFER_MODE,BUFFMODE)
  __DECLARE_LOCATED(BOOL,X1)
  __DECLARE_LOCATED(BOOL,X2)
  __DECLARE_LOCATED(BOOL,X3)
  __DECLARE_LOCATED(BOOL,X4)
  MC_READACTUALPOSITION MC_READACTUALPOSITION0;
  PROC_STATE PROC_STATE0;
  MC_SETPOSITION MC_SETPOSITION0;
  __DECLARE_VAR(MC_EXECUTION_MODE,MC_SETPOSMODE)
  MC_HOME MC_HOME2;
  MC_MOVEABSOLUTE MC_MOVEABSOLUTE1;
  MC_POWER MC_POWER1;
  MC_READACTUALPOSITION MC_READACTUALPOSITION1;
  PROC_STATE PROC_STATE1;
  MC_SETPOSITION MC_SETPOSITION1;
  MC_HOME MC_HOME3;
  MC_MOVEABSOLUTE MC_MOVEABSOLUTE2;
  MC_POWER MC_POWER2;
  MC_READACTUALPOSITION MC_READACTUALPOSITION2;
  PROC_STATE PROC_STATE2;
  MC_SETPOSITION MC_SETPOSITION2;
  WK_PID WK_PID1;
  WK_PID WK_PID2;
  WK_PID WK_PID3;
  MC_HOME MC_HOME1;
  MC_MOVEABSOLUTE MC_MOVEABSOLUTE3;
  MC_POWER MC_POWER3;
  MC_READACTUALPOSITION MC_READACTUALPOSITION3;
  PROC_STATE PROC_STATE3;
  MC_SETPOSITION MC_SETPOSITION3;
  MC_WRITEPARAMETER MC_WRITEPARAMETER0;
  MC_WRITEPARAMETER MC_WRITEPARAMETER1;
  MC_WRITEPARAMETER MC_WRITEPARAMETER2;
  MC_WRITEPARAMETER MC_WRITEPARAMETER3;
  MC_WRITEPARAMETER MC_WRITEPARAMETER4;
  MC_WRITEPARAMETER MC_WRITEPARAMETER5;
  MC_WRITEPARAMETER MC_WRITEPARAMETER6;
  MC_WRITEPARAMETER MC_WRITEPARAMETER7;
  MC_WRITEPARAMETER MC_WRITEPARAMETER8;
  MC_WRITEPARAMETER MC_WRITEPARAMETER9;
  MC_WRITEPARAMETER MC_WRITEPARAMETER10;
  MC_WRITEPARAMETER MC_WRITEPARAMETER11;
  WK_HYP WK_HYP1;
  WK_HYP WK_HYP2;
  WK_HYP WK_HYP4;
  WK_HYP WK_HYP0;
  STEPPER STEPPER3;
  STEPPER STEPPER0;
  STEPPER STEPPER1;
  STEPPER STEPPER2;
  __DECLARE_VAR(REAL,_TMP_ADD221_OUT)
  __DECLARE_VAR(REAL,_TMP_ADD103_OUT)
  __DECLARE_VAR(REAL,_TMP_ADD223_OUT)
  __DECLARE_VAR(REAL,_TMP_ADD227_OUT)
  __DECLARE_VAR(UINT,_TMP_REAL_TO_UINT31_OUT)
  __DECLARE_VAR(UINT,_TMP_REAL_TO_UINT25_OUT)
  __DECLARE_VAR(UINT,_TMP_REAL_TO_UINT63_OUT)
  __DECLARE_VAR(UINT,_TMP_REAL_TO_UINT96_OUT)
  __DECLARE_VAR(REAL,_TMP_SUB200_OUT)
  __DECLARE_VAR(REAL,_TMP_SUB185_OUT)
  __DECLARE_VAR(REAL,_TMP_SUB215_OUT)
  __DECLARE_VAR(REAL,_TMP_SUB177_OUT)

} PROGRAM0;

void PROGRAM0_init__(PROGRAM0 *data__, BOOL retain);
// Code part
void PROGRAM0_body__(PROGRAM0 *data__);
#endif //__POUS_H
void PROGRAM0_Input(PROGRAM0 *data__);
void PROGRAM0_Output(PROGRAM0 *data__);